/**
 * 加密
 * @param {String} str 需要加密的字符串
 * @param {String} key 密钥（24位）
 */
function encryptByDES(str, key) {
    var keyHex = CryptoJS.enc.Utf8.parse(key);
    var encrypted = CryptoJS.TripleDES.encrypt(str, keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7  //后端pkcs5填充，前端对应pkcs7
    });
    return encrypted.toString()
}


/**
 * 
 * @param {String} str 需要解密的字符串
 * @param {String} key 密钥（24位）
 */
function decryptByDES(str, key) {
    var keyHex = CryptoJS.enc.Utf8.parse(key);
    var decrypted = CryptoJS.TripleDES.decrypt(str, keyHex, {
        mode:CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7 //后端pkcs5填充，前端对应pkcs7
    });
    return decrypted.toString(CryptoJS.enc.Utf8)
}


function formKey(){
    let time = new Date().getTime();
    return encryptByDES(window.btoa(unescape(encodeURIComponent(time))),"wikcnV9ysUtuJrAdvhBkaT-9")
}
